clear
use  ${data}teacher_data

* Limit data to Chicago region
keep if region==1
 
* Inflate binary outcomes by factor of 100
replace ans_satis = ans_satis * 100

eststo clear 
foreach c in ans_satis satisfaction min_gm   { 

	reg `c' da i.hs i.CorpsYear  $X  , cluster(region_gl)
	eststo `c'
	gen s=e(sample)
	estadd scalar p = 2*ttail(1,abs(_b[da]/_se[da])): `c'
	qui su `c' if da==1 & s==1
	estadd scalar cm = round(r(mean) - _b[da],.001): `c'
	drop s

	
 }
  
  estout ans_satis satisfaction min_gm  ///
	using ${results}table6_panelA.txt, replace ///
	keep(da) cells(b(star fmt(2) nostar)  se(par fmt(3))) ///
	collabels(,none) stat(p cm  N)	

 
 
* Parallel Trends Figure *
	
reg min_gm da2009 da2010 da2011 da2012 da2014 i.hs i.CorpsYear  $X, cluster(region_gl)

matrix coef = J(6,3,.)
local row=0
foreach y in 2009 2010 2011 2012   { 
	local row=`row'+1
	matrix coef[`row',1] = `y'
	matrix coef[`row',2] = _b[da`y']
	matrix coef[`row',3] = _se[da`y']
}
matrix coef[5,1] = 2013
matrix coef[5,2] = 0
matrix coef[5,3] = 0
matrix coef[6,1] = 2014
matrix coef[6,2] = _b[da2014]
matrix coef[6,3] = _se[da2014]
 
clear
svmat coef
ren coef1 cohort
ren coef2 effect

* Confidence intervals use 1 degree of freedom
gen lb = effect - 12.7062*coef3
gen ub = effect + 12.7062*coef3
	

	
graph twoway (connected effect cohort, lcolor(black) mcolor(black)) (rcap ub lb cohort, lcolor(black)), xline(2013.1, lcolor(black) lpattern(dash))    legend(label(1 "Effect")  label(2 "95% Confidence Interval") pos(6) cols(1)) graphregion(color(white)) xtitle("Cohort") ytitle("HS-Elementary Difference") 
graph export ${results}figure4_panelA.png, replace
 
   
exit
 
